<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import ="com.popcorn.member.model.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>


<script type="text/javascript">

	function formCheck() {

		var password = document.getElementById('password');
		var password_hint = document.getElementById('password_hint');
		var password_check = document.getElementById('password_check');
		var hp1 = document.getElementById('hp1'); 
		var hp2 = document.getElementById('hp2'); 
		var hp3 = document.getElementById('hp3'); 
		var hp = hp1.value + "-" + hp2.value + "-" + hp3.value;
		
		/*핸드폰 번호 길이 체크*/
		
		if (password.value == '' || password.value == null) {
			alert('비밀번호를 입력하세요');
			focus.password;
			return false;
		}
		
		else if (password_check.value == '' || password_check.value == null) {
			alert('비밀번호확인란을 입력하세요');
			focus.password_hint;
			return false;
		}
		
		/*비밀번호와 비밀번호확인란 같은지 확인*/
		else if (password.value != password_check.value){
			alert("비밀번호와 비밀번호 확인란이 다릅니다.");
			focus.passowrd;
			return false;
		}
		
 		/*핸드폰 번호 길이 체크*/
 		else if(hp2.value.length<=2 || hp3.value.length!=4){
			alert("휴대폰번호를 제대로 입력해주세요");
			focus.hp2;
			return false;
		}
 		/*핸드폰이 숫자만 들어가는지 체크*/
 		else if(isNaN(hp2.value) || isNaN(hp3.value))
		{
			alert("휴대폰번호는 숫자만 들어갈 수 있습니다.");
			return false;
		}
 		else update();
	}

	function update() {
// 		alert($("#password_hint").val());
// 		alert($("#member_HP").val());
		var str3 = document.getElementById('update');
		str3.submit();
		alert("수정이 완료되었습니다.")
	}
	
</script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>회원가입</title>
<!-- 탑 인클루드 -->
<jsp:include page="/main/header.jsp"></jsp:include>
<body bgcolor="#ffffff" text="#000000">
<br><br><br><br><br>
<%
	MemberVo member = new MemberVo();
	member = (MemberVo) request.getAttribute("user");
	String [] hp = member.getHp().split("-");	
%>
<div class="content_inner">   <div class="container">   <div class="container_inner clearfix">
	<p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p>

	<P align="center">
		<FONT size="6"><B>회원 수정</B></FONT>
	</P>

<p>&nbsp;</p>
	<form action="./update.ho" method="post" id="update">
		<table width="550" align="center" border="1" bordercolor="ADD8E6"
			cellpadding="5">
			<tr>
				<td height="30" align="center" bgcolor="#FFDEAD">이름</td>
				<td bgcolor="#E0FFFF"><%= member.getName()%></td>
			</tr>
			
			<tr>
				<td height="30" align="center" bgcolor="#FFDEAD">닉네임</td>
				<td bgcolor="#E0FFFF"><%= member.getNickname()%></td>
			</tr>
			
			<tr>
				<td height="30" align="center" bgcolor="#FFDEAD">비밀번호</td>
				<td bgcolor="#E0FFFF"><input type="password" id="password" name="member_password" size=12 maxlength="12"></td>
			</tr>
			<tr>
				<td height="30" align="center" bgcolor="#FFDEAD">비밀번호확인</td>
				<td bgcolor="#E0FFFF"><input type="password" id="password_check" name="password_check" size=12 maxlength="12"></td>
			</tr>
			<tr>
				<td rowspan="2" height="30" align="center" bgcolor="#FFDEAD">연락처</td>
				<td bgcolor="#E0FFFF">
					<select id="hp1" name="hp1" style="width:70;">
					   <option value="010" <%if("010".equals(hp[0])) out.print("selected=\"selected\""); %>> 010 </option>
					   <option value="011" <%if("011".equals(hp[0])) out.print("selected=\"selected\""); %>> 011 </option>
					   <option value="016" <%if("016".equals(hp[0])) out.print("selected=\"selected\""); %>> 016 </option>
					   <option value="017" <%if("017".equals(hp[0])) out.print("selected=\"selected\""); %>> 017 </option>
					   <option value="018" <%if("018".equals(hp[0])) out.print("selected=\"selected\""); %>> 018 </option>
					   <option value="019" <%if("019".equals(hp[0])) out.print("selected=\"selected\""); %>> 019 </option>
					</select>
					-
					<input type="text" id="hp2" name="hp2" size="4" maxlength="4" value="<%= hp[1]%>">
					-
					<input type="text" id="hp3" name="hp3" size="4" maxlength="4" value="<%= hp[2]%>">
				</td>
			</tr>
			<tr>
				<td colspan="2" height="30" align="center" bgcolor="#FFDEAD">
				<input type="button" id="update" name="update" value="수정하기" onclick="javascript:formCheck();">&nbsp;&nbsp; <input type="reset" value="리셋하기" onclick='init()'>
				<input type="button" id="back" value="뒤로가기" onclick="javascript:location.href='/loginpage.do';"></td>
			</tr>
		</table>
	</form> </div></div></div>
</body>
</html>